package com.achievement.controller;

import com.achievement.domain.dto.honor.ReviewSchemeDTO;
import com.achievement.domain.param.honor.ReviewSchemeParam;
import com.achievement.domain.vo.honor.ReviewSchemeVO;
import com.achievement.service.IReviewSchemeService;
import com.common.annotation.Anonymous;
import com.common.annotation.Log;
import com.common.core.controller.BaseController;
import com.common.core.domain.AjaxResult;
import com.common.core.page.TableDataInfo;
import com.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "成果管理-评审方案")
@RestController
@RequestMapping("/achievement/reviewScheme")
public class ReviewSchemeController extends BaseController {
    @Autowired
    private IReviewSchemeService reviewSchemeService;

    @PreAuthorize("@ss.hasPermi('achievement:reviewScheme:list')")
    @ApiOperation("获取评审方案列表")
    @GetMapping("/list")
    public TableDataInfo list(ReviewSchemeParam param)
    {
        startPage();
        List<ReviewSchemeVO> list = reviewSchemeService.selectByPage(param);
        return getDataTable(list);
    }


    /**
     * 获取评审方案详细信息
     */
    @PreAuthorize("@ss.hasPermi('achievement:reviewScheme:query')")
    @ApiOperation("获取评审方案详情")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(reviewSchemeService.getInfoById(id));
    }

    /**
     * 新增评审方案
     */
    @PreAuthorize("@ss.hasPermi('achievement:reviewScheme:add')")
    @ApiOperation("新增评审方案")
    @Log(title = "新增评审方案", businessType = BusinessType.INSERT)
    @PostMapping(value = "/add")
    public AjaxResult add(@RequestBody ReviewSchemeDTO dto)
    {
        return toAjax(reviewSchemeService.add(dto));
    }

    /**
     * 修改评审方案
     */
    @PreAuthorize("@ss.hasPermi('achievement:reviewScheme:update')")
    @ApiOperation("修改评审方案")
    @Log(title = "修改评审方案", businessType = BusinessType.UPDATE)
    @PutMapping(value = "/update")
    public AjaxResult edit(@RequestBody ReviewSchemeDTO dto)
    {
        return toAjax(reviewSchemeService.update(dto));
    }

    /**
     * 删除评审方案
     */
    @PreAuthorize("@ss.hasPermi('achievement:reviewScheme:remove')")
    @ApiOperation("删除评审方案")
    @Log(title = "删除评审方案", businessType = BusinessType.DELETE)
    @DeleteMapping("/del/{ids}")
    public AjaxResult remove(@PathVariable List<String> ids)
    {
        return toAjax(reviewSchemeService.batchRemove(ids));
    }
}
